package config.fullandlitemode;

import com.dao.UserDao;
import com.dao.UserDaoImpl;
import com.service.UserService;
import com.service.UserServiceImpl;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;

@Configuration(proxyBeanMethods = false)
public class FullAndLiteMode {
    @Bean(initMethod = "init")
    public UserDaoImpl userDao() {
        System.out.println("bean方法：注册UserDao");
        return new UserDaoImpl();
    }

    @Bean
    @Scope("prototype")
    public UserService userService() {
        System.out.println("bean方法：注册UserService");

        UserServiceImpl userService = new UserServiceImpl();
        UserDao dao = userDao();
        userService.setDao(dao);
        return userService;
    }
}
